<template>
	<view>
		<view class="wrapper">
			<view class="name-list">
				<view class="name-item" v-for="name in localNames">
					<text>
						{{name}}
					</text>
					<view class="add-cart" @click="delFromStorage(name)">
						移除备选
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				localNames: []
			}
		},

		onLoad() {
			// 从本地存储读取姓名列表
			this.localNames = uni.getStorageSync("local-name") || []
		},
		methods: {
			delFromStorage(name) {

				this.localNames = this.localNames.filter(item => item != name)
				uni.setStorageSync("local-name", this.localNames)
			}
		}
	}
</script>

<style lang="scss">
	.name-list {
		font-size: 36rpx;

		.name-item {
			min-height: 100px;
			border-radius: 20rpx;
			box-sizing: border-box;
			padding: 20rpx;
			background-color: #fff;
			margin-bottom: 20rpx;
			padding-bottom: 100rpx;
			position: relative;

			.add-cart {
				background-color: red;
				color: #fff;
				text-align: center;
				padding: 12rpx 24rpx;
				border-radius: 40rpx;
				position: absolute;
				right: 20rpx;
				bottom: 20rpx;
			}
		}
	}
</style>